package p800;

public class Leetcode_896 {
    public static boolean isMonotonic(int[] A) {
        if (A.length <= 1) {
            return true;
        }
        short flag = 0;
        short flagg = 0;
        for (int i = 1; i < A.length; i++) {
            if (A[i] > A[i - 1]) {
                flag = 1;
            }
            if (A[i] < A[i - 1]) {
                flagg = -1;
            }
        }
        return flag * flagg >= 0;
    }

    public static void main(String[] args) {

        System.out.println(isMonotonic(new int[]{1, 1, 2}));
    }
}